package com.ruoyi.project.wodemand.controller;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.project.wodemand.domain.SelectVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.wodemand.domain.TSheetnode;
import com.ruoyi.project.wodemand.service.ITSheetnodeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 工单处理节点Controller
 *
 * @author lt
 * @date 2020-04-14
 */
@RestController
@RequestMapping("/wodemand/SHEETNODE")
public class TSheetnodeController extends BaseController
{
    @Autowired
    private ITSheetnodeService tSheetnodeService;

    /**
     * 查询工单处理节点列表
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSheetnode tSheetnode)
    {
        startPage();
        List<TSheetnode> list = tSheetnodeService.selectTSheetnodeList(tSheetnode);
        return getDataTable(list);
    }

    /**
     * 查询工单类型
     */
    @CrossOrigin
    @GetMapping("/sheetType")
    public AjaxResult getSheetType()
    {
        List<SelectVo> list = tSheetnodeService.getSheetType();
        AjaxResult aTrue = new AjaxResult(200, "true", list);
        return aTrue;
    }

    /**
     * 导出工单处理节点列表
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:export')")
    @Log(title = "工单处理节点", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TSheetnode tSheetnode)
    {
        List<TSheetnode> list = tSheetnodeService.selectTSheetnodeList(tSheetnode);
        ExcelUtil<TSheetnode> util = new ExcelUtil<TSheetnode>(TSheetnode.class);
        return util.exportExcel(list, "SHEETNODE");
    }

    /**
     * 获取工单处理节点详细信息
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:query')")
    @GetMapping(value = "/{sheetTypeId}")
    public AjaxResult getInfo(@PathVariable("sheetTypeId") String sheetTypeId)
    {
        return AjaxResult.success(tSheetnodeService.selectTSheetnodeById(sheetTypeId));
    }

    /**
     * 新增工单处理节点
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:add')")
    @Log(title = "工单处理节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSheetnode tSheetnode)
    {
        return toAjax(tSheetnodeService.insertTSheetnode(tSheetnode));
    }

    /**
     * 修改工单处理节点
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:edit')")
    @Log(title = "工单处理节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSheetnode tSheetnode)
    {
        return toAjax(tSheetnodeService.updateTSheetnode(tSheetnode));
    }

    /**
     * 删除工单处理节点
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETNODE:remove')")
    @Log(title = "工单处理节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sheetTypeIds}")
    public AjaxResult remove(@PathVariable String[] sheetTypeIds)
    {
        return toAjax(tSheetnodeService.deleteTSheetnodeByIds(sheetTypeIds));
    }
}
